{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=52
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var  	
	ls,t,kk,ts,code:longint;
	a:array[0..100010] of longint;
	s,tt:string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
fillchar(a,sizeof(a),0);
readln(s);
s:=trim(s);
ls:=length(s);
t:=0;
while ls>0 do begin
	kk:=pos(' ',s);
	if kk>0 then begin
		tt:=copy(s,1,kk-1);
		delete(s,1,kk);
	end else begin
		tt:=s;
		s:='';
	end;
	val(tt,ts,code);
	if code=0 then begin
		inc(t);
		a[t]:=ts;
	end else begin
		if tt='*' then begin
			a[t-1]:=a[t-1]*a[t];
			dec(t);
		end else 
		if tt='+' then begin
			inc(a[t-1],a[t]);
			dec(t);
		end else
		if tt='-' then begin
			dec(a[t-1],a[t]);
			dec(t);
		end;
	end;
	ls:=length(s);
end;
write(a[1]);
end.